#ifndef __XKK_TASKQUEUE_H__
#define __XKK_TASKQUEUE_H__

#include "MutexLock.hpp"
#include "Condition.hpp"
#include <functional>
#include <queue>

using std::queue;
namespace xkk
{

using ElemType=std::function<void()>;

class TaskQueue
{
public:
    TaskQueue(size_t); 

    bool full() const;
    bool empty() const;
    void push(ElemType elem);
    ElemType pop();

    void wakeup();
private:
    size_t _queSize;
    queue<ElemType> _que;
    MutexLock _mutex;
    Condition _notFull;
    Condition _notEmpty;
    bool _flag;
    
};

}//end of namespace xkk
#endif
